const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  // 代理/res路径的请求
  app.use('/res', createProxyMiddleware({ 
    target: 'http://localhost:7001',
    changeOrigin: true,
    onProxyReq: (proxyReq) => {
      console.log('代理请求路径:', proxyReq.path); // 打印实际转发路径
    }
  }));
  
  // 代理/api路径的请求
  app.use('/api', createProxyMiddleware({ 
    target: 'http://localhost:7001',
    changeOrigin: true,
    onProxyReq: (proxyReq) => {
      console.log('代理请求路径:', proxyReq.path); // 打印实际转发路径
    }
  }));
  app.use('/static', createProxyMiddleware({ 
    target: 'http://localhost:7001',
    changeOrigin: true,
    onProxyReq: (proxyReq) => {
      console.log('代理请求路径:', proxyReq.path); // 打印实际转发路径
    }
  }));
};